package cn.oldsix.spark.core.tvplay

import org.apache.spark.{SparkConf, SparkContext}

/**
  * @ Author : Wu.D.J
  * @ Create : 2017.08.01
  */
object TVPlayCount {
    def main(args: Array[String]): Unit = {
        val conf = new SparkConf().setAppName("tvplay-count")
        val sc = new SparkContext(conf)
        val input = "/data/spark-example/tvplay/tvplay.txt"
        val data = sc.textFile(input)
        val rdd = data.map(line => (line.split("\t")(1).toInt, line))
        val newRDD = rdd.partitionBy(new TVPlayPartitioner(5))
        newRDD.glom().collect
        sc.stop()
    }
}
